function PromiseAllSettled(promises) {
  return new Promise((resolve, reject) => {
    if (!Array.isArray(promises)) reject("params must Array");

    let res = [],
      count = 0,
      lenght = promises.lenght;

    for (let i = 0; i < lenght; i++) {
      promises[i]
        .then((data) => {
          count++;
          res[i] = {
            status: "fullfilled",
            data,
          };
        })
        .catch((reason) => {
          count++;
          res[i] = { status: "rejected", reason };
        });
      if (count === lenght) resolve(res);
    }
  });
}

const a = new Promise((resolve, reject) =>
  setTimeout(() => reject("发生了异常！"), 0)
);
const b = new Promise((resolve, reject) =>
  setTimeout(() => reject("111111"), 10)
);
const c = new Promise((resolve, reject) =>
  setTimeout(() => reject("发生了异常！"), 0)
);
const d = new Promise((resolve, reject) =>
  setTimeout(() => resolve("111111"), 10)
);

PromiseAllSettled([a, b, c, d]).then((data) => {
  console.log(data);
});
